package com.lwc.mapper;


import com.lwc.bean.MaterialStock;
import com.lwc.bean.MaterialStockQuery;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface MaterialStockMapper {
    List<MaterialStock> query(MaterialStockQuery materialStockQuery);
    /**
     * 加库存
     * @param sum
     * @return
     */
    @Update("update material_stock set stock=stock+#{sum} where id=#{id}")
    int plus(@Param("sum") int sum,@Param("id") int id);


    /**
     * 新增列表
     */
    @Insert("insert into material_stock(material_code,material_name,stock,unit,status,last_time,type) " +
            "values (#{material_code},#{material_name},#{stock},#{unit},#{status},now(),#{type})")
    int insert(MaterialStock materialStock);

    /**
     * 通过id查看库存
     * @param ids
     * @return
     */
    @Select("select  stock   from material_stock where id=#{ids}")
    int querystock(int ids);


    List<MaterialStock> export();

    @Select("select    DATE_FORMAT(godown_time, '%Y-%m-%d %H:%i')godown_time,godown_code,id,sum,godown_type,user_name  from godown_entry where  id=#{id}")
    Map queryorderById(int id);


    int insertMultipartFileByExcel(List list);
}
